<template>
  <div class="app-container">
    <el-form class="search-form" :inline="true">
      <el-form-item class="form-button-bar">
        <el-button class="filter-item el-icon-upload2" @click="handleOnline" type="success">&nbsp;上线
        </el-button>
        <el-button class="filter-item el-icon-back" style="margin-left: 10px;" @click="handleRevocation" type="warning">&nbsp;撤回
        </el-button>
        <el-button class="filter-item el-icon-delete" style="margin-left: 10px;" @click="handleDeleteList" type="danger">&nbsp;失效
        </el-button>
        <el-button class="filter-item el-icon-circle-check-outline" style="margin-left: 10px;" @click="handleAudited" type="primary">&nbsp;审核通过
        </el-button>
        <el-button :loading="refreshing" class="filter-item el-icon-refresh" style="margin-left: 10px;" @click="refreshList" type="danger">&nbsp;刷新列表
        </el-button>
        <el-button plain class="search-bar-button" style="float: right;border-width: 2px" type="primary" @click="searchBarVisable = !searchBarVisable">
          {{searchBarVisable?'收起':'展开'}}搜索项<i :class="searchBarVisable?'el-icon-caret-top':'el-icon-caret-bottom'"></i>
        </el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="20">
      <el-col :span="20" style="border-right:1px solid #dcdfe6">
        <el-form class="search-form" label-width="120px" ref="listQuery" :model="listQuery">
          <div :class="searchBarVisable?'':'search-bar-hide'" style="transition:  all .3s ease-in-out;">
            <el-row>
              <el-col :span="12">
                <el-form-item label="标题" label-width="80px">
                  <el-input style="max-width: 500px" :clearable="true" v-model="listQuery.title" placeholder="请输入"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="数据库" prop="tbSourceId" label-width="80px">
                  <el-select v-model="listQuery.tbSourceId" type="text" clearable  placeholder="请选择" @change="dblistchange">
                    <el-option v-for="(option, index) in dbList" :key="option.id" :value="option.id" :label="option.dbConfigName"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="所属栏目" prop="newsClassId" label-width="80px">
                  <el-popover placement="bottom-start" trigger="click" @show="filterText1 = ''">
                    <el-input placeholder="输入关键字进行过滤" v-model="filterText1">
                    </el-input>
                    <el-tree :filter-node-method="filterNode" ref="tree4" :props="props" :data="treeList" :highlight-current="false" node-key="code" :default-expanded-keys="[0]"
                      :render-content="renderClassContent">
                    </el-tree>
                    <el-select :clearable="true" popper-class="hide" slot="reference" v-model="listQuery.cmsNewsClassId" type="text" placeholder="请输入">
                      <el-option v-for="(item, index) in options" v-show="false" :key="index" :value="item.id" :label="item.name"></el-option>
                    </el-select>
                  </el-popover>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="第三方所属栏目" prop="newsClassId" label-width="120px">
                  <el-select v-model="listQuery.thirdPartClassId" clearable type="text" placeholder="请选择">
                    <el-option v-for="(option, index) in thirdlist" :key="option.classId" :value="option.classId" :label="option.className"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="态度" label-width="80px">
              <el-radio v-model="listQuery.attitude" label="" border size="mini">全部</el-radio>
              <el-radio v-model="listQuery.attitude" label="-2" border size="mini">无态度</el-radio>
              <el-radio v-model="listQuery.attitude" label="-1" border size="mini">利空</el-radio>
              <el-radio v-model="listQuery.attitude" label="0" border size="mini">中性</el-radio>
              <el-radio v-model="listQuery.attitude" label="1" border size="mini">利好</el-radio>
            </el-form-item>
            <el-row>
              <el-col :span="12" v-for="(k,index) in listQuery.tagList" :key="k.id">
                <el-row>
                  <el-col :span="14">
                    <el-form-item :label="tagName[k.tagType]+'标签'" label-width="80px">
                      <el-select v-model="k.tagCode" value-key="tag_code" clearable filterable remote reserve-keyword placeholder="请输入关键词"
                        :remote-method="((query)=>{remoteMethodSearch(k.tagType,query)})" :loading="loading">
                        <el-option v-for="item in searchOptions[tagType[k.tagType]]" :key="item.tag_code" :label="item.name" :value="item.tag_code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="10">
                    <el-form-item label="权重打分" label-width="80px">
                      <el-row>
                        <el-col :span="13">
                          <el-select v-model="k.tagComparision" clearable placeholder="">
                            <el-option v-for="item in qzoptions" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                          </el-select>
                        </el-col>
                        <el-col :span="11">
                          <el-input :clearable="true" v-model="k.tagScore" placeholder="分数"></el-input>
                        </el-col>
                      </el-row>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-form-item label='来源' label-width='80px'>
                <el-input placeholder="请输入" v-model="listQuery.source"></el-input>
            </el-form-item>
            <el-form-item label="审核状态" label-width="80px">
              <el-radio v-model="listQuery.viewStatus" label="" border size="mini">全部</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="0" border size="mini">未审核</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="1" border size="mini">已审核</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="2" border size="mini">已上线</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="3" border size="mini">已撤回</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="4" border size="mini">已驳回</el-radio>
              <el-radio v-model="listQuery.viewStatus" label="6" border size="mini">已失效</el-radio>
            </el-form-item>
            <el-form-item label="推送方式" label-width="80px">
              <el-radio v-model="listQuery.pushChannel" label="" border size="mini">全部</el-radio>
              <el-radio v-model="listQuery.pushChannel" label="全员推送" border size="mini">全员推送</el-radio>
              <el-radio v-model="listQuery.pushChannel" label="不推送" border size="mini">不推送</el-radio>
              <el-radio v-model="listQuery.pushChannel" label="按板块推送" border size="mini">按板块推送</el-radio>
              <el-radio v-model="listQuery.pushChannel" label="按个股推送" border size="mini">按个股推送</el-radio>
            </el-form-item>
            <el-form-item label="更新时间" label-width="80px">
              <el-radio  v-model="listQuery.chooseTime" label="" border size="mini">自定义</el-radio>
              <el-radio  v-model="listQuery.chooseTime" label="1" border size="mini">今天</el-radio>
              <el-radio  v-model="listQuery.chooseTime" label="3" border size="mini">近三天</el-radio>
            </el-form-item>
            <el-form-item label="" label-width="80px">
              <el-date-picker :clearable="true" type="datetimerange" :default-time="['00:00:00', '23:59:59']" @change="listQuery.chooseTime = ''" @keyup.enter.native="getList" style="width: 450px;"
                class="filter-item" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" v-model="listQuery.updateTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="发布时间" label-width="80px">
              <el-radio-group v-model="listQuery.chooseTime2">
                  <el-radio   label="" border size="mini">自定义</el-radio>
                  <el-radio   label="1" border size="mini">今天</el-radio>
                  <el-radio   label="3" border size="mini">近三天</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="" label-width="80px">
              <el-date-picker :clearable="true" type="datetimerange" :default-time="['00:00:00', '23:59:59']" @change="listQuery.chooseTime2 = ''" @keyup.enter.native="getList" style="width: 450px;"
                class="filter-item" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" v-model="listQuery.publishTime">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button class="filter-item" type="primary" icon="el-icon-search" @click="getList">
                查询
              </el-button>
              <el-button class="filter-item" type="primary" icon="el-icon-search" @click="saveSearchlist">
                保存
              </el-button>
              <el-button class="filter-item" type="primary" icon="el-icon-search" @click="resetSearch">
                重置
              </el-button>
            </el-form-item>
          </div>
        </el-form>
      </el-col>
      <el-col :span="4" :class="searchBarVisable?'':'search-bar-hide'">
        <b>已保存的查询条件：</b>
        <el-row  v-for="k in searchlist" :key="k.id">
          <el-col :span="24" style="margin-top:10px" >
            <el-tag closable style="cursor: pointer;" size="medium" @click.native="getSearchData(k)" @close="handleClose(k)">{{k.name}}</el-tag>
          </el-col>
        </el-row>
      </el-col>
    </el-row>

    <el-table class='wrap-table-cell' :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="加载中..." border fit highlight-current-row @selection-change="handleSelectionChange" style="width: 100%">
      <el-table-column align="center" type="selection" width="55">
      </el-table-column>
      <el-table-column align="center" label="标题" min-width="200">
        <template slot-scope="scope">
          <el-button class="preview-button" type="text" @click="handleShow(scope.row)">{{scope.row.title}}</el-button>
        </template>
      </el-table-column>
       <el-table-column align="center" label="发布时间" width="100">
        <template slot-scope="scope">
          <span>{{scope.row.publishTime}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="排序时间" width="100">
        <template slot-scope="scope">
          <span>{{scope.row.orderTime}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="更新时间" width="100">
        <template slot-scope="scope">
          <span>{{scope.row.updateTime}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="所属栏目">
        <template slot-scope="scope">
          <el-tooltip :visible-arrow="false" class="tooltip" effect="dark" :content="scope.row.newsClassStr" placement="top-start">
            <span class="nowrap">{{scope.row.newsClassStr}}</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核状态">
        <template slot-scope="scope">
          <el-tag size="small" :type="formatClass(scope.row.viewStatus)">{{formatStatu(scope.row.viewStatus)}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核未通过原因" min-width="250" >
        <template slot-scope="scope">
          <!-- <div v-html="formateStr(scope.row.auditRejectMessage)"></div> -->
           <div v-if="!formatReject(scope.row.auditRejectMessage).id" v-html="filterStr(scope.row.auditRejectMessage)"></div>
          <div v-else>
            <div v-html="formatReject(scope.row.auditRejectMessage).nopase"></div>
            {{formatReject(scope.row.auditRejectMessage).text.split('【')[0]}}
            <el-button class="preview-button" type="text" @click="handleShow(formatReject(scope.row.auditRejectMessage))">
              {{(formatReject(scope.row.auditRejectMessage).text.replace(/(^[^【]*)|([^】]*$)/g, ''))}}
            </el-button>
             {{formatReject(scope.row.auditRejectMessage).text.split('】')[1]}}
            <div v-html="formatReject(scope.row.auditRejectMessage).time"></div>
            <div v-html="formatReject(scope.row.auditRejectMessage).extra"></div>
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核人">
        <template slot-scope="scope">
          <span>{{scope.row.auditor}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="来源">
        <template slot-scope="scope">
          <span>{{scope.row.source}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="推送方式">
        <template slot-scope="scope">
          <span>{{scope.row.sendChannel}}</span>
        </template>
      </el-table-column>
    </el-table>

    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNum" :page-sizes="[10,20,30, 50]"
        :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
    <el-dialog :fullscreen='true' :title="'查看'" :visible.sync="dialogFormVisible">
      <el-form :rules="rules" :model="temp" label-position="left" label-width="130px" style='margin: auto; max-width: 1200px'>
        <el-form-item label="标题" prop="title">
          <el-input disabled v-model="temp.title" type="text"></el-input>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="股票">
               <el-tooltip v-for="tag in temp.stockInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name+'('+tag.code+')'}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.stockInfos" :key="tag.tag_code">{{tag.name+'('+tag.code+')'}}</el-tag> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="基金">
              <el-tooltip v-for="tag in temp.fundInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name+'('+tag.code+')'}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.fundInfoslist" :key="tag.tag_code">{{tag.name+'('+tag.code+')'}}</el-tag> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="主题">
              <el-tooltip v-for="tag in options0" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in options0" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="行业">
              <el-tooltip v-for="tag in options1" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in options1" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="市场">
              <el-tooltip v-for="tag in temp.marketInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.marketInfos" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人物">
              <el-tooltip v-for="tag in temp.peopleInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.peopleInfos" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地域">
              <el-tooltip v-for="tag in temp.districtInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.districtInfos" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织">
              <el-tooltip v-for="tag in temp.organInfos" :key="tag.tag_code+Math.random()" class="item" effect="dark" :content="String(tag.score)">
                <el-tag>{{tag.name}}</el-tag>
              </el-tooltip>
              <!-- <el-tag v-for="tag in temp.organInfos" :key="tag.tag_code">{{tag.name}}</el-tag> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="核心标签(主)" prop="mainKeyword">
              <el-tag v-for="tag in temp.mainKeyword" :key="tag">{{tag}}</el-tag>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="核心标签(副)" prop="viceKeyword">
              <el-tag v-for="tag in temp.viceKeyword" :key="tag">{{tag}}</el-tag>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="所属栏目" prop="newsClassId">
              <el-select value-key='id' multiple popper-class="hide" disabled v-model="temp.newsClassId" type="text" placeholder="请输入">
                <el-option v-for="(item,index) in options" :key="item.id" :value="item" :label="item.name"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="第三方栏目" prop="events">
              <el-tag v-for="tag in temp.thirdPartClassVOS" :key="tag.className">{{tag.className}}</el-tag>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="数据源来源" prop="tbSource">
              <el-input v-model="temp.tbSource" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6" style="line-height:36px;color: #666666;font-weight: 700;">App场景运营标记:</el-col>
          <el-col :span="6">
            <el-form-item label="覆盖类型" prop="ranges">
              <el-select v-model="temp.ranges" type="text" placeholder="请选择">
                <el-option v-for="item in rangesOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="展示场景" prop="scene">
              <el-select multiple v-model="temp.scene" type="text" placeholder="请选择">
                <el-option v-for="item in sceneOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="新闻类型" prop="newstype">
              <el-select v-model="temp.newstype" type="text" placeholder="请选择">
                <el-option v-for="item in newstypeOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="态度" prop="attitude">
              <el-select disabled v-model="temp.attitude" type="text" placeholder="请选择">
                <el-option :value="-2" label="无态度"></el-option>
                <el-option :value="-1" label="利空"></el-option>
                <el-option :value="0" label="中性"></el-option>
                <el-option :value="1" label="利好"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="状态" prop="online">
              <el-select disabled v-model="temp.online" type="text" placeholder="请选择">
                <el-option :value="0" label="立即上线"></el-option>
                <el-option :value="1" label="暂缓上线"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="推送方式" prop="sendChannel">
              <el-select disabled :default-first-option="true" v-model="temp.sendChannel" type="text" placeholder="请选择">
                <el-option value="全员推送" label="全员推送"></el-option>
                <el-option value="不推送" label="不推送"></el-option>
                <el-option value="按板块推送" label="按板块推送"></el-option>
                <el-option value="按个股推送" label="按个股推送"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="置顶时间" prop="topTime">
              <el-input disabled v-model="temp.topTime" type="text" placeholder="选择日期"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="摘要" prop="summary">
              <el-input disabled v-model="temp.summary" type="textarea" :rows="5" placeholder="请输入">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="正文预览" prop="content">
              <el-tabs type="card" @tab-click="handleTabClick">
                <el-tab-pane label="手机预览">
                  <el-card class="phone">
                    <div class="top-bar">
                      资讯预览
                    </div>
                    <div class="title">{{temp.title}}</div>
                    <div class="info">
                      <span>来源：{{formatSource(temp.source)}}&emsp;</span>
                      <span>发布时间：{{temp.publishTime}}</span>
                    </div>
                    <div class="summary">摘要：{{temp.summary}}</div>
                    <div class="content">
                      <p v-html="temp.content"></p>
                    </div>
                  </el-card>
                </el-tab-pane>
                <el-tab-pane label="PC预览">
                  <el-card class="pc">
                    <div class="title">{{temp.title}}</div>
                    <div class="info">
                      <span>来源：{{formatSource(temp.source)}}&emsp;</span>
                      <span>发布时间：{{temp.publishTime}}</span>
                    </div>
                    <div class="summary">摘要：{{temp.summary}}</div>
                    <div class="content">
                      <p v-html="temp.content"></p>
                    </div>
                  </el-card>
                </el-tab-pane>
              </el-tabs>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="发布时间" prop="publishTime">
              <el-input disabled v-model="temp.publishTime" type="text" :rows="5" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="来源" prop="source">
              <el-select disabled v-model="temp.source" type="text" placeholder="请选择">
                <el-option v-for="(item, index) in dataDict.news_source" :key="item.dictValue" :value="item.dictValue" :label="item.dictValue"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item>
              <el-button plain class="search-bar-button" style="border-width: 2px" type="primary" @click="extendBarVisable = !extendBarVisable">{{extendBarVisable?'收起':'展开'}}附加字段<i
                  :class="extendBarVisable?'el-icon-caret-top':'el-icon-caret-bottom'"></i>
              </el-button>
            </el-form-item>
          </el-col>
          <el-col v-show="extendBarVisable" v-for="i of 10" :key='i' :span="24">
            <el-form-item :label="'附加字段'+i" :prop="'additional_'+ i">
              <el-input disabled v-model="temp['additional_'+ (i-1)]" type="text" placeholder=""></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <el-form-item label="资讯配图">
              <span v-if="!image">暂无配图</span>
              <img style="max-height: 300px" :src="image.url" :alt="image.name">
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="success" @click="updateAppStatus">更新App标记</el-button>
<!--        <el-button type="success" @click="handleUpdateTime">更新排序</el-button>-->
        <el-button type="primary" @click="dialogFormVisible = false">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="查询条件" :visible.sync="searchDialogVisible" :close-on-click-modal="false" width="40%" style="margin-top: -6rem;" append-to-body>
      <el-form :rules="searchFormrules" label-position="left" label-width="130px" style='margin: 24px;'>
        <el-form-item label="名称" prop="name">
          <el-input v-model="listQuery.name" type="text" placeholder="请输入">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="searchDialogVisible = false">{{$t('table.cancel')}}</el-button>
        <el-button v-if="listQuery.id" type="primary" @click="updateSearchlist">{{$t('table.confirm')}}</el-button>
        <el-button v-else type="primary" @click="createSearchlist">{{$t('table.confirm')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  articlePlateList,
  articleStockList,
  articleAuditList,
  userClassList,
  articleGet,
  articleList,
  batchDelete,
  updateAppScene,
  articleDelete,
  batchAudited,
  batchOnline,
  batchRevocation,
  addCondition,
  getCondition,
  updateCondition,
  searchConditionList,
  newsListByCondition,
  thirdPartClassList,
  tagsSearch,
  deleteCondition, updateOrderTime
} from '../../api/article'
import { databaseList } from "../../api/data";
import { getTypeDict } from "../../api/systemManagement";
import waves from "@/directive/waves"; // 水波纹指令
import pinyin from "pinyin";

export default {
  name: "complexTable",
  directives: {
    waves,
  },
  components: {},
  watch: {
    filterText1(val) {
      this.$refs.tree1.filter(val);
    },
    filterText2(val) {
      this.$refs.tree2.filter(val);
    },
    "listQuery.chooseTime"(val) {
      if (val) {
        const endTime = new Date(
          new Date().getFullYear(),
          new Date().getMonth(),
          new Date().getDate() + 1
        ).getTime();
        this.listQuery.updateTime = [
          endTime - 24 * 3600 * 1000 * val,
          endTime - 1000,
        ];
      }
    },
    "listQuery.chooseTime2"(val){
       if (val) {
        const endTime = new Date(
          new Date().getFullYear(),
          new Date().getMonth(),
          new Date().getDate() + 1
        ).getTime();
        this.listQuery.publishTime = [
          endTime - 24 * 3600 * 1000 * val,
          endTime - 1000,
        ];
      }
    }
  },
  data() {
    return {
      filterText1: "",
      filterText2: "",
      multipleSelection: [],
      multipleSelectionIds: [],
      props: {
        label: "name",
        id: "code",
        key: "code",
      },
      tableKey: 0,
      list: null,
      total: null,
      refreshing: false,
      listLoading: true,
      editLoading: false,
       tagList_copy: [
          {
            name: "股票",
            tagCode: "",
            tagType: "0",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "基金",
            tagCode: "",
            tagType: "1",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "主题",
            tagCode: "",
            tagType: "2",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "行业",
            tagCode: "",
            tagType: "3",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "市场",
            tagCode: "",
            tagType: "4",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "人物",
            tagCode: "",
            tagType: "5",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "地域",
            tagCode: "",
            tagType: "6",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "组织",
            tagCode: "",
            tagType: "7",
            tagScore: "",
            tagComparision: "",
          },
        ],
      listQuery: {
        id: "",
        name:'',
        pageNum: 1,
        pageSize: 20,
        title: "",
        attitude: "",
        auditStatus: "",
        author: "",
        source: "",
        cmsNewsClassId: "",
        plateCode: "",
        pushChannel: "",
        stockCode: "",
        viewStatus: "",
        chooseTime: "",
        chooseTime2: "",
        updateTime: [
          new Date(
            new Date().getFullYear(),
            new Date().getMonth(),
            new Date().getDate() + 1
          ).getTime() -
            24 * 3600 * 1000,
          new Date(
            new Date().getFullYear(),
            new Date().getMonth(),
            new Date().getDate() + 1
          ).getTime() - 1000,
        ],
        publishTime: ["", ""],
        scene: "",
        tagList: [
          {
            name: "股票",
            tagCode: "",
            tagType: "0",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "基金",
            tagCode: "",
            tagType: "1",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "主题",
            tagCode: "",
            tagType: "2",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "行业",
            tagCode: "",
            tagType: "3",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "市场",
            tagCode: "",
            tagType: "4",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "人物",
            tagCode: "",
            tagType: "5",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "地域",
            tagCode: "",
            tagType: "6",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "组织",
            tagCode: "",
            tagType: "7",
            tagScore: "",
            tagComparision: "",
          },
        ],
        tbSourceId: "",
        thirdPartClassId: "",
      },
      tagType: {
        0: "stock",
        1: "fund",
        2: "theme",
        3: "industry",
        4: "market",
        5: "people",
        6: "districts",
        7: "organs",
      },
      tagName: {
        0: "股票",
        1: "基金",
        2: "主题",
        3: "行业",
        4: "市场",
        5: "人物",
        6: "地域",
        7: "组织",
      },
      preview: false,
      searchForm: {
        name: "",
        id: "",
      },
      searchDialogVisible: false,
      dialogFormVisible: false,
      searchFormrules: {
        name: [
          {
            type: "string",
            required: true,
            message: "请输入...",
            trigger: "blur",
          },
        ],
      },
      dialogVisible: false,
      extendBarVisable: false,
      showReviewer: false,
      stockSearch: "",
      temp: {
        attitude: 0,
        author: "",
        source: "",
        isOriginal: 0,
        content: "",
        sendChannel: "",
        newsClassId: [],
        newsPlateCodes: [],
        newsPlateCodes0: [],
        newsPlateCodes1: [],
        newsPlateCodes2: [],
        newsStockCodes: [],
        online: 1,
        topTime: "",
        summary: "",
        title: "",
        enterTime: "",
      },
      dialogStatus: "",
      textMap: {
        update: "编辑",
        create: "新增",
      },
      dialogPvVisible: false,
      stockLib: [],
      treeList: [{ name: "栏目列表", code: 0, children: [] }],
      treeList0: [{ name: "概念板块", code: 0, children: [] }],
      treeList1: [{ name: "行业板块", code: 0, children: [] }],
      treeList2: [{ name: "原创板块", code: 0, children: [] }],
      options: [],
      options0: [],
      options1: [],
      options2: [],
      rangesOptions: [
        {
          value: 0,
          label: "空白",
        },
        {
          value: 1,
          label: "按全市场来",
        },
        {
          value: 2,
          label: "按行业",
        },
        {
          value: 3,
          label: "按个股",
        },
      ],
      sceneOptions: [
        {
          value: "0",
          label: "空白",
        },
        {
          value: "1",
          label: "银小河浮窗",
        },
        {
          value:'2',
          label:"基金动态"
        }
      ],
      newstypeOptions: [
        {
          value: 0,
          label: "空白",
        },
        {
          value: 1,
          label: "新闻",
        },
        {
          value: 2,
          label: "重磅",
        },
        {
          value: 3,
          label: "突发",
        },
        {
          value: 4,
          label: "解读",
        },
        {
          value: 5,
          label: "异动",
        },
        {
          value: 6,
          label: "公告",
        },
      ],
      pvData: [],
      rules: {},
      downloadLoading: false,
      image: "",
      imageType: "",
      imageList: [],
      previewData: "",
      previewDialogVisible: false,
      imageLoading: false,
      imageListLoading: false,
      imageListVisible: false,
      isUpdate: false,
      dataDict: {
        news_source: [],
      },
      searchBarVisable: false,
      pickerOptions: {
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              const end =
                new Date(
                  new Date().getFullYear(),
                  new Date().getMonth(),
                  new Date().getDate() + 1
                ).getTime() - 1000;
              const start = end + 1000 - 3600 * 1000 * 24;
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三天",
            onClick(picker) {
              const end =
                new Date(
                  new Date().getFullYear(),
                  new Date().getMonth(),
                  new Date().getDate() + 1
                ).getTime() - 1000;
              const start = end + 1000 - 3600 * 1000 * 24 * 3;
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一周",
            onClick(picker) {
              const end =
                new Date(
                  new Date().getFullYear(),
                  new Date().getMonth(),
                  new Date().getDate() + 1
                ).getTime() - 1000;
              const start = end + 1000 - 3600 * 1000 * 24 * 7;
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      dataForm: {},
      value: "",
      value1: "",
      dbList: [],
      loading: false,
      thirdlist: [],
      searchlist: [],
      qzoptions: [
        {
          value: "0",
          label: "=",
        },
        {
          value: "1",
          label: ">",
        },
        {
          value: "2",
          label: "≥",
        },
        {
          value: "3",
          label: "<",
        },
        {
          value: "4",
          label: "≤",
        },
      ],
      searchOptions: {
        stock: [],
        fund: [],
        theme: [],
        industry: [],
        market: [],
        people: [],
        district: [],
        organ: [],
      },
    };
  },
  created() {
    this.getDict();
    this.getdatabaseList();
    this.getList();
    this.getClass();
    this.getsearchlist();
  },
  methods: {
    handleUpdateTime(){
      let params = {
        id:this.temp.id
      }
      updateOrderTime(params).then(res=>{
        console.log(res)
        if(res.Meta.Code===0){
          this.$notify({
            title: "更新状态",
            message: "更新成功",
            type: "success",
            duration: 2000
          });
        }else{
          this.$notify({
            title: "更新状态",
            message: "更新失败",
            type: "error",
            duration: 2000
          });
        }
      })
    },
    getdatabaseList() {
      databaseList({
        pageNum: 1,
        pageSize: 9999,
      }).then((response) => {
        this.dbList = response.Data;
      });
    },
    getDict() {
      getTypeDict({ type: "news_source" }).then((response) => {
        this.dataDict.news_source = response.Data;
      });
    },
    formatContent(data) {
      if (!data.content) return;
      console.log(data)
      const keyword = [];
      // console.log(data)
      // if (data.newsStockCodes && data.newsStockCodes.length > 0) {
      //   keyword.push(
      //     data.newsStockCodes
      //       .map((val) => {
      //         val.replace('(','|')
      //         val.replace(')','')
      //         // return val.replace(/\(\d*(\d{5,6})\)/, "|$1");
      //         return val
      //       })
      //       .join("|")
      //   );
      // }
      if (data.stockInfos && data.stockInfos.length > 0) {
        keyword.push(
          data.stockInfos
            .map((val) => {
              return val.name
            })
            .join('|')
        )
      }
      if (data.newsPlateCodes0 && data.newsPlateCodes0.length > 0) {
        keyword.push(
          data.newsPlateCodes0
            .map((val) => {
              return val.code + "|" + val.name;
            })
            .join("|")
        );
      }
      if (data.newsPlateCodes1 && data.newsPlateCodes1.length > 0) {
        keyword.push(
          data.newsPlateCodes1
            .map((val) => {
              return val.code + "|" + val.name;
            })
            .join("|")
        );
      }
      if (data.newsPlateCodes2 && data.newsPlateCodes2.length > 0) {
        keyword.push(
          data.newsPlateCodes2
            .map((val) => {
              return val.code + "|" + val.name;
            })
            .join("|")
        );
      }
      if(data.fundInfos && data.fundInfos.length>0 ){
        keyword.push(
          data.fundInfos
            .map((val) => {
              return val.name
            })
            .join('|')
        )
      }
      // data.content = data.content.replace(/^(\s*)?\n(\s*\n)?/, '')
      // data.content = data.content.replace(/\r\n|\r|\n/g, '<br />')
      if (keyword.length === 0) return data.content;
      // const contentReg = new RegExp(
      //   '(?!<[^>]*)(' + keyword.join('|').replace(/\*/g, "\\*") + ')(?![^<]*>)',
      //   "g"
      // )
      const contentReg = new RegExp(
        '(?!<[^>]*)(' + keyword.join('|').replace(/\*/g, '\\*') + ')(?![^<]*>)',
        'g'
      )
      // const contentReg = new RegExp('(' + keyword + ')','g')
      // console.log('contentReg',contentReg)
      return data.content.replace(
        contentReg,
        '<span class="news-keyword">$1</span>'
      );
    },
    filterNode(value, data) {
      if (!value) return true;
      return (
        data.name.indexOf(value) !== -1 ||
        pinyin(data.name, {
          style: pinyin.STYLE_FIRST_LETTER,
          heteronym: true,
        })
          .join("")
          .indexOf(value) !== -1
      );
    },
    handleSelectionChange(val) {
      this.multipleSelectionIds = val.map((e) => e.id);
      this.multipleSelection = val;
    },
    handleOnline() {
      const ids = this.multipleSelection
        .filter((e) => e.viewStatus === 1)
        .map((e) => e.id);
      if (ids.length === 0) return;
      batchOnline(ids).then(() => {
        this.getList();
        this.$notify({
          title: "成功",
          message: "上线成功",
          type: "success",
          duration: 2000,
        });
      });
    },
    handleRevocation() {
      const ids = this.multipleSelection
        .filter((e) => e.viewStatus === 2)
        .map((e) => e.id);
      if (ids.length === 0) return;
      batchRevocation(ids).then(() => {
        this.getList();
        this.$notify({
          title: "成功",
          message: "撤回成功",
          type: "success",
          duration: 2000,
        });
      });
    },
    handleAudited() {
      const ids = this.multipleSelection
        .filter(
          (e) =>
            e.viewStatus === 0 && e.creater !== this.$store.state.user.userCode
        )
        .map((e) => e.id);
      if (ids.length === 0) return;
      batchAudited(ids).then(() => {
        this.getList();
        this.$notify({
          title: "成功",
          message: "审核成功",
          type: "success",
          duration: 2000,
        });
      });
    },
    handleDeleteList() {
      if (this.multipleSelectionIds.length === 0) {
        this.$message({ type: "warning", message: "请勾选需要删除的数据" });
        return;
      }
      this.$confirm(
        "一旦失效，该篇资讯将彻底下线并且不可编辑，是否继续？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).then(() => {
        batchDelete(this.multipleSelectionIds).then(() => {
          this.getList();
          this.$notify({
            title: "成功",
            message: "失效成功",
            type: "success",
            duration: 2000,
          });
        });
      });
    },
    formatAttitude(data) {
      switch (data) {
        case -1:
          return "利空";
        case 0:
          return "中性";
        case 1:
          return "利好";
      }
    },
    formatClass(data) {
      switch (data) {
        case 0:
          return "danger"; // '未审核'
        case 1:
          return "success"; // '已审核'
        case 2:
          return "primary"; // '已上线'
        case 3:
          return "warning"; // '已撤回'
        case 4:
          return "warning"; // '已驳回'
        case 5:
          return "warning"; // '未发布'
        case 6:
          return "info"; // '已失效'
      }
    },
    formatStatu(data) {
      switch (data) {
        case 0:
          return "未审核";
        case 1:
          return "已审核";
        case 2:
          return "已上线";
        case 3:
          return "已撤回";
        case 4:
          return "已驳回";
        case 5:
          return "未发布";
        case 6:
          return "已失效";
      }
    },
    formatAudit(data) {
      switch (data) {
        case 0:
          return "已审核";
        default:
          return "未审核";
      }
    },
    formatOnline(data) {
      switch (data) {
        case 0:
          return "上线";
        case 1:
          return "下线";
        case 2:
          return "已撤回";
      }
    },
    formatSource(data) {
      for (let i = 0; i < this.dataDict.news_source.length; i++) {
        if (this.dataDict.news_source[i].dictKey === data) {
          return this.dataDict.news_source[i].dictValue;
        }
      }
      return data;
    },
    refreshList() {
      this.refreshing = true;
      this.listQuery.title = this.listQuery.title.trim();
      const params = Object.assign({}, this.listQuery);
      if (this.listQuery.updateTime) {
        params.startUpdateTime = this.listQuery.updateTime[0];
        params.endUpdateTime = this.listQuery.updateTime[1];
      } else {
        params.startUpdateTime = "";
        params.endUpdateTime = "";
      }
      articleAuditList(params)
        .then((response) => {
          this.refreshing = false;
          this.list = response.Data;
          this.total = parseInt(response.total);
          this.$message({
            message: "刷新成功",
            type: "success",
          });
        })
        .catch(() => {
          this.refreshing = false;
        });
    },
    getList() {

      let tagScoreFlag = true;
      let tempList = this.listQuery.tagList;
      for (let index = 0; index < tempList.length; index++) {
        const element = tempList[index];
        if((element.tagComparision!==''&&element.tagScore!=="")||(element.tagComparision ===''&&element.tagScore==="")){

        } else{
          tagScoreFlag = false;
          break;
        }
      }

      if(!tagScoreFlag){
       this.$message({
          message: '标签搜索请填写完整，权重 分数和范围必填！',
          type: 'warning'
        });
        return false
      }

      this.listLoading = true;
      this.listQuery.title = this.listQuery.title.trim();
      const params = Object.assign({}, this.listQuery);
      if (this.listQuery.updateTime) {
        params.startUpdateTime = this.listQuery.updateTime[0];
        params.endUpdateTime = this.listQuery.updateTime[1];
      } else {
        params.startUpdateTime = "";
        params.endUpdateTime = "";
      }

      if(this.listQuery.publishTime){
        params.startPublishTime = this.listQuery.publishTime[0];
        params.endPublishTime = this.listQuery.publishTime[1]
      }else{
         params.startPublishTime ='';
         params.endPublishTime = '';
      }


      newsListByCondition(params).then((response) => {
        this.listLoading = false;
        this.list = response.Data;
        this.total = parseInt(response.total);
      });
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.getList();
    },
    resetTemp() {
      this.temp = {
        attitude: 0,
        author: "",
        source: "",
        isOriginal: 0,
        content: "",
        sendChannel: "",
        newsClassId: [],
        newsPlateCodes: [],
        newsPlateCodes0: [],
        newsPlateCodes1: [],
        newsPlateCodes2: [],
        newsStockCodes: [],
        online: 1,
        topTime: "",
        summary: "",
        title: "",
        enterTime: "",
        ranges: 0,
        scene: ["0"],
        newstype: 0,
      };
    },
    handleShow(row) {
      row.editLoading = true;
      this.isUpdate = false;
      articleGet(row).then((response) => {
        this.temp = Object.assign({}, response.Data[0]);
        var ranges = this.temp.ranges;
        var scene =
          this.temp.scene === undefined
            ? ["0"]
            : this.temp.scene.split(",").filter((item) => {
                return item !== "";
              });
        var newstype = this.temp.newstype;
        for (let i = 0; i < this.temp.newsInfoExtends.length; i++) {
          this.temp["additional_" + this.temp.newsInfoExtends[i].extendIndex] =
            this.temp.newsInfoExtends[i].extendContent || "";
        }
        this.image = response.Data[0].pictureEntity || "";
        const tempVal1 = [];
        const tempVal2 = this.temp.stockInfos.map((e) => {
          tempVal1.push(`${e.name}(${e.code})`);
          return {
            key: `${e.name}(${e.code})`,
            label: `${e.name}(${e.code})`,
          };
        });
        this.stockLib = tempVal2;
        this.$set(this.temp, "newsStockCodes", Object.assign([], tempVal1));
        this.$set(
          this.temp,
          "newsPlateCodes0",
          Object.assign([], this.temp.conceptInfos)
        );
        this.$set(
          this.temp,
          "newsPlateCodes1",
          Object.assign([], this.temp.industryInfos)
        );
        this.$set(
          this.temp,
          "newsPlateCodes2",
          Object.assign([], this.temp.userDefinedInfos)
        );
        this.$set(
          this.temp,
          "newsClassId",
          Object.assign([], this.temp.classInfos)
        );
        this.$set(this.temp, "ranges", ranges);
        this.$set(this.temp, "scene", scene);
        this.$set(this.temp, "newstype", newstype);
        this.options = this.temp.classInfos;
        this.options0 = this.temp.conceptInfos;
        this.options1 = this.temp.industryInfos;
        this.options2 = this.temp.userDefinedInfos;
        this.dialogStatus = "update";
        this.dialogFormVisible = true;
        if (this.$refs.editor) this.$refs.editor.setContent(this.temp.content);
        this.$nextTick(() => {
          this.$refs["dataForm"].clearValidate();
        });
        row.editLoading = false;

        this.$nextTick(()=>{
          let strongs = document.querySelectorAll('.phone .content>p strong')
          for (let i = 0; i <strongs.length ; i++) {
            if(strongs[i].getAttribute('data-code')){
              let text= strongs[i].innerText
              strongs[i].innerHTML = `<span class="news-keyword">${text}</span>`
            }
          }
        })

        this.$nextTick(()=>{
          let strongs = document.querySelectorAll('.pc .content>p strong')
          for (let i = 0; i <strongs.length ; i++) {
            if(strongs[i].getAttribute('data-code')){
              let text= strongs[i].innerText
              strongs[i].innerHTML = `<span class="news-keyword">${text}</span>`
            }
          }
        })
      });
    },
    handleTabClick(node){
      if(node.paneName==='0'){
        this.$nextTick(()=>{
          let strongs = document.querySelectorAll('.phone .content>p strong')
          for (let i = 0; i <strongs.length ; i++) {
            if(strongs[i].getAttribute('data-code')){
              let text= strongs[i].innerText
              strongs[i].innerHTML = `<span class="news-keyword">${text}</span>`
            }
          }
        })
      }else{
        this.$nextTick(()=>{
          let strongs = document.querySelectorAll('.pc .content>p strong')
          for (let i = 0; i <strongs.length ; i++) {
            if(strongs[i].getAttribute('data-code')){
              let text= strongs[i].innerText
              strongs[i].innerHTML = `<span class="news-keyword">${text}</span>`
            }
          }
        })
      }
    },
    formatReject(val) {
      let result;
        try {
          result = JSON.parse(val);
        } catch (e) {
          let tempStr = [];

          if(val.indexOf('$')>-1&&val.indexOf('{')===-1){
            tempStr = val.split('$');
            result = tempStr;
          }else if(val.indexOf('$')>-1&&val.indexOf('{')>-1){
             tempStr = val.split('$');
              try{
               if(tempStr[0].indexOf('{')>-1){
                   result  = JSON.parse(tempStr[0]);
                   result['time'] = tempStr[1];
                }else{
                   result  = JSON.parse(tempStr[1]);
                   result['nopase'] = tempStr[0];
                }
                if(tempStr.length>2){
                  result['extra'] = tempStr[2];
                }
              }catch(err){
               console.log(err);
              }
          }else{
            result = val;
          }
        }

        return result;
    },
    filterStr(value){
         let val = this.formatReject(value);
        if(typeof(val) ==='string'){
            return `${val}`
        }else if(Array.isArray(val)){
          if(val.length>2){
            return `<div>${val[0]}</div><div>${val[1]}</div><div>${val[2]}</div>`
          }
          return `<div>${val[0]}</div><div>${val[1]}</div>`
        }else if(typeof(val)==='number'){
          return `<div>${val}</div>`
        }
        else{
           return `<div>${val.text}</div><div>${val.time}</div>`
        }
    },
    updateAppStatus() {
      var params = {};
      params.id = this.temp.id;
      params.scene = this.temp.scene.join(",");
      params.ranges = this.temp.ranges;
      params.newstype = this.temp.newstype;
      updateAppScene(params)
        .then(() => {
          this.$notify({
            title: "成功",
            message: "更新App运营场景标记成功",
            type: "success",
            duration: 2000,
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "更新App运营场景标记失败",
          });
        });
    },
    handleDelete(row) {
      this.$confirm(
        "一旦失效，该篇资讯将彻底下线并且不可编辑，是否继续？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          articleDelete(row).then(() => {
            this.$notify({
              title: "成功",
              message: "失效成功",
              type: "success",
              duration: 2000,
            });
            this.getList();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消失效",
          });
        });
    },
    renderClassContent(h, { node, data, store }) {
      return (
        <span
          class={
            node.isLeaf && node.level > 1
              ? "custom-tree-node"
              : "custom-tree-node custom-tree-notLeaf"
          }
        >
          <span>{node.label}</span>
          <span>
            {node.level > 1 && node.isLeaf ? (
              <el-button
                size="mini"
                type="text"
                on-click={() => (this.listQuery.cmsNewsClassId = data.id)}
              >
                选择
              </el-button>
            ) : (
              ""
            )}
          </span>
        </span>
      );
    },
    getClass() {
      const params = {
        pageNum: 1,
        pageSize: 99999,
      };
      userClassList(params).then((response) => {
        const temp = {};
        const result = [];
        const data = response.Data;
        const length = data.length;
        for (let i = 0; i < length; i++) {
          temp[data[i].id] = data[i];
          this["options"].push(data[i]);
        }
        for (let i = 0; i < length; i++) {
          if (temp[data[i].id].parentId && temp[data[i].parentId]) {
            if (!temp[data[i].parentId].children) {
              temp[data[i].parentId].children = [];
            }
            temp[data[i].parentId].children.push(temp[data[i].id]);
          } else {
            result.push(temp[data[i].id]);
          }
        }
        // this['treeList'][0].children = result
        this.$set(this["treeList"][0], "children", result);
      });
    },
    searchStock(e) {
      if (e.trim() === "") {
        this.$message({
          type: "warning",
          message: "请输入有效查询内容！",
        });
        return;
      }
      const params = {
        pageNum: 1,
        pageSize: 99999,
        phoneticChars: e,
      };
      articleStockList(params).then((response) => {
        const stocks = [];
        this.stockLib = response.Data.map((e) => {
          stocks.push(`${e.name}(${e.code})`);
          return {
            key: `${e.name}(${e.code})`,
            label: `${e.name}(${e.code})`,
          };
        });
        this.temp.newsStockCodes.forEach((e) => {
          if (stocks.indexOf(e) === -1) {
            this.stockLib.push({
              key: e,
              label: e,
            });
          }
        });
      });
    },
    createSearchlist() {
      // this.searchDialogVisible=false
       if(!this.listQuery.name){
          this.$message.warning('创建名称，不能为空!');
          return false;
        }

      if(this.listQuery.publishTime.length==2){
        this.listQuery.endPublishTime= new Date(this.listQuery.publishTime[1]) ;
        this.listQuery.startPublishTime=new Date(this.listQuery.publishTime[0]);
      }
      if(this.listQuery.updateTime.length==2){
        this.listQuery.endUpdateTime= new Date(this.listQuery.updateTime[1]);
        this.listQuery.startUpdateTime=new Date(this.listQuery.updateTime[0]);
      }

      addCondition(this.listQuery).then((res) => {
        this.searchDialogVisible = false;
        if (res.Meta.Code === 0) {
          this.$message.success("保存成功");
          this.getsearchlist();
          this.listQuery.name=""
        } else {
          this.$message.success("保存失败");
          this.listQuery.name=""
        }
      });
    },
    updateSearchlist() {

        if(!this.listQuery.name){
          this.$message.warning('保存名称，不能为空!');
          return false;
        }


      if(this.listQuery.publishTime.length==2){
        this.listQuery.endPublishTime= new Date(this.listQuery.publishTime[1]) ;
        this.listQuery.startPublishTime=new Date(this.listQuery.publishTime[0]);
      }
      if(this.listQuery.updateTime.length==2){
        this.listQuery.endUpdateTime= new Date(this.listQuery.updateTime[1]);
        this.listQuery.startUpdateTime=new Date(this.listQuery.updateTime[0]);
      }



      updateCondition(this.listQuery).then((res) => {
        this.searchDialogVisible = false;
        if (res.Meta.Code === 0) {
          this.$message.success("更新成功");
          this.getsearchlist();
          this.listQuery.name=""
        } else {
          this.$message.success("更新失败");
          this.listQuery.name=""
        }
      });
    },
    saveSearchlist() {
      this.searchDialogVisible = true;
    },
    resetSearch() {
      this.listQuery = {
        id:'',
        pageNum: 1,
        pageSize: 20,
        title: "",
        attitude: "",
        auditStatus: "",
        author: "",
        source: "",
        cmsNewsClassId: "",
        plateCode: "",
        pushChannel: "",
        stockCode: "",
        viewStatus: "",
        chooseTime: "",
        chooseTime2: "",
        updateTime: [
          new Date(
            new Date().getFullYear(),
            new Date().getMonth(),
            new Date().getDate() + 1
          ).getTime() -
            24 * 3600 * 1000,
          new Date(
            new Date().getFullYear(),
            new Date().getMonth(),
            new Date().getDate() + 1
          ).getTime() - 1000,
        ],
        publishTime: ["", ""],
        scene: "",
        tagList: [
          {
            name: "股票",
            tagCode: "",
            tagType: "0",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "基金",
            tagCode: "",
            tagType: "1",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "主题",
            tagCode: "",
            tagType: "2",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "行业",
            tagCode: "",
            tagType: "3",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "市场",
            tagCode: "",
            tagType: "4",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "人物",
            tagCode: "",
            tagType: "5",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "地域",
            tagCode: "",
            tagType: "6",
            tagScore: "",
            tagComparision: "",
          },
          {
            name: "组织",
            tagCode: "",
            tagType: "7",
            tagScore: "",
            tagComparision: "",
          },
        ],
        tbSourceId: "",
        thirdPartClassId: ""
      };
      this.listQuery.endPublishTime='';
      this.listQuery.endUpdateTime='';
      this.listQuery.startPublishTime='';
      this.listQuery.startUpdateTime='';
      this.getList();
    },
    remoteMethodSearch(type, query) {
      if (query !== "") {
        this.loading = true;
        tagsSearch({
          type: this.tagType[type],
          key: query,
        }).then((res) => {
          const list = res.Data.map((i) => {
          if(type==='0'||type==='1'){
                return {
                  ...i,
                  tag_code: i.tagCode,
                  name:i.name+`(${i.code})`
                };
          }else{
            return {
              ...i,
              tag_code: i.tagCode
            };
          }

          });
          this.searchOptions[this.tagType[type]] = list;
          console.log(this.searchOptions);
          this.loading = false;
        });
      } else {
        this.searchOptions[this.tagType[type]] = [];
        this.loading = false;
      }
    },
    dblistchange() {
      if (this.listQuery.tbSourceId !== "") {
        thirdPartClassList(this.listQuery.tbSourceId, {}).then((res) => {
          this.thirdlist = res.Data;
        });
      }
    },
    getsearchlist() {
      searchConditionList({
        pageNum: 1,
        pageSize: 20,
      }).then((res) => {
        this.searchlist = res.Data;
      });
    },
    searchTagFetchList(type,query){

      return new Promise((resolve,reject)=>{
           tagsSearch({
              type: this.tagType[type],
              key: query,
            }).then((res) => {
                const list = res.Data.map((i) => {
                  if(type==='0'||type==='1'){
                        return {
                          ...i,
                          tag_code: i.tagCode,
                          name:i.name+`(${i.code})`
                        };
                  }else{
                    return {
                      ...i,
                      tag_code: i.tagCode
                    };
                  }

                });

                resolve(list);
            })
      })

    },
    getSearchData(data) {
      let that  = this;
      getCondition(data.id, {}).then((res) => {
        if (res.Data.length > 0) {

          let tagList = res.Data[0].tagList&& res.Data[0].tagList.length>0? res.Data[0].tagList:[];

          let searchOPtions = {...that.searchOptions};

          tagList.map( async val=>{
              let type = that.tagType[ parseInt(val.tagType)];

              if(val.tagType==='0'||val.tagType==='1'){
                  let options = await that.searchTagFetchList(val.tagType,val.tagName);
                  console.log('options',options);
                  searchOPtions[type] = [{
                      name:options[0].name,
                      tag_code:val.tagCode,
                  }]
                  console.log(searchOPtions[type])
              }else{
                 searchOPtions[type] = [{
                    name:val.tagName,
                    tag_code:val.tagCode,
                }]
              }
          })

          let searchObj = {...res.Data[0]};
          let tagList_ = [...searchObj.tagList];
          let tagList_old = [...that.tagList_copy];
          tagList_.map( val=>{
            tagList_old[parseInt(val.tagType)] = val;
          })

          setTimeout(()=>{
            that.searchOptions = {...searchOPtions};
            that.listQuery = {...that.listQuery,...searchObj,tagList:tagList_old};
            this.listQuery.updateTime = [new Date(searchObj.startUpdateTime),new Date(searchObj.endUpdateTime)]
            this.listQuery.publishTime = [new Date(searchObj.startPublishTime),new Date(searchObj.endPublishTime)]
            that.listQuery.viewStatus +=""
            that.dblistchange();
          },1000)

        }
      });
    },
    handleClose(data) {
      deleteCondition({
        id:data.id
      }).then(res=>{
        if(res.Meta.Code===0){
          this.$message.success('删除成功')
          this.getsearchlist();
        }else{
          this.$message.success('删除失败')
        }
      })
    },
    formateStr(val){
      if(val.indexOf('\\n')>-1){
          let strList = val.split('\\n');
          return `<div>${strList[0]}</div><div>${strList[1]}</div>`
        }else{
          return `${val}`
        }
    },
    changePublishTime(val){
      if(val===''){
        this.listQuery.chooseTime2 = [];
      }else if(val==='1'){
        this.listQuery.chooseTime2 = [new Date(),new Date()]
      }else{
         this.listQuery.chooseTime2 = [new Date(new Date().setDate(new Date().getDate() - 3)),new Date()]
      }
    }
  },
};
</script>

<style>
.hide {
  display: none;
}

.el-dialog__body {
  padding: 24px;
  line-height: normal;
}

.nowrap {
  white-space: nowrap;
}

.el-tooltip__popper {
  max-width: 50%;
}
</style>

<style scoped>
::v-deep .wrap-table-cell .el-table .cell{
  white-space:pre-line;
}
</style>
<style lang="stylus" scoped>
.phone {
  word-break: break-all;
  line-height: 24px;
  margin: auto;
  width: 375px;
  height: 600px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    display: none;
  }

  .top-bar {
    text-align: center;
    padding: 10px 15px;
    margin: 0 -20px;
    position: absolute;
    top: 0;
    width: 373px;
    background-color: #000;
    color: #fff;
    font-size: 120%;
    font-weight: bold;
  }

  .title {
    text-align: justify;
    margin-top: 52px;
    font-size: 110%;
    font-weight: bolder;
  }

  .info {
    font-size: 85%;
    color: #5d5d5d;
  }

  .summary {
    text-align: justify;
    padding: 5px 10px;
    margin: 10px 0 10px;
    font-size: 90%;
    line-height: 1.2rem;
    color: #333;
    border-radius: 5px;
    background-color: #ddd;
  }

  .content {
    text-align: justify;

    &:after {
      display: inline-block;
      content: '';
      padding-left: 100%;
    }
  }
}

.pc {
  word-break: break-all;
  line-height: 24px;
  font-size: 16px;
  margin: auto;
  width: 100%;
  height: 600px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    display: none;
  }

  .title {
    text-align: justify;
    margin-top: 12px;
    font-size: 120%;
    font-weight: bolder;
  }

  .info {
    font-size: 85%;
    color: #5d5d5d;
  }

  .summary {
    text-align: justify;
    padding: 5px 10px;
    margin: 10px 0;
    font-size: 90%;
    line-height: 1.2rem;
    color: #333;
    border-radius: 5px;
    background-color: #ddd;
  }

  .content {
    text-align: justify;

    &:after {
      display: inline-block;
      content: '';
      padding-left: 100%;
    }
  }
}

.image-button {
  padding: 10px;
  background-color: transparent;
  border: none;
  width: 100%;

  &:hover {
    box-shadow: 0 0 10px #aaa;
    border: #aaa;
  }
}
</style>

